import * as fs from 'fs';


/**
 * 同步获取指定目录下的所有子文件夹名称
 * @param {string} directoryPath - 目标目录的路径
 * @returns {string[]} - 子文件夹名称数组
 */
function getSubFoldersSync(directoryPath: string): string[] {
    try {
        const files = fs.readdirSync(directoryPath, {withFileTypes: true});
        return files.filter(file => file.isDirectory()).map(file => file.name);
    } catch (err: any) {
        throw new Error(`读取目录时出错: ${err.message}`);
    }
}

export default getSubFoldersSync;